#ifndef CHANGES_MANAGER_H
#define CHANGES_MANAGER_H

#include <mutex>
#include <set>
#include <unordered_map>
#include <vector>

#include "common/api/changes.h"
#include "common/api/result.hpp"

#include "common/elements/element_type.hpp"

#include "common/more/uuid.h"

class ChangesManager final
{
public:
    void push(Elements::ElementType type, unsigned id);
    void push(Elements::ElementType type, std::vector<unsigned> ids);

    Api::Changes pop(const Uuids::Uuid& sessionUuid);

    void erase(
        const Uuids::Uuid& sessionUuid,
        Elements::ElementType type,
        unsigned id
    );
    void erase(
        const Uuids::Uuid& sessionUuid,
        Elements::ElementType type,
        const std::vector<unsigned>& ids
    );

    void addSession(const Uuids::Uuid& sessionUuid);
    void removeSession(const Uuids::Uuid& sessionUuid);

private:
    std::mutex m_locker;
    std::unordered_map<Uuids::Uuid, Api::Changes> m_sessionChanges;
};

#endif // CHANGES_MANAGER_H
